﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace PRE.Report_Catalog
{
    public partial class FrmThongke_Doanhthu_Theolop : DevExpress.XtraEditors.XtraForm
    {
        DAL.EntitesDAL.KhoahocDAL _dal = new DAL.EntitesDAL.KhoahocDAL();
        DAL.EntitesDAL.PhieuthuDAL _dal1 = new DAL.EntitesDAL.PhieuthuDAL();

        public FrmThongke_Doanhthu_Theolop()
        {
            InitializeComponent();
        }

        private void cboKhoahoc_EditValueChanged(object sender, EventArgs e)
        {
            DataTable tmp = _dal.Select_Current(DateTime.Now);
            string makhoa = tmp.Rows[0]["Makhoa"] + "";
            DataTable dtb = _dal1.Select(makhoa);

            if (dtb != null)
                grcMain.DataSource = dtb;

            DataTable dtb1 = _dal1.Select_Sum(makhoa);
            Decimal _tongtien = Convert.ToInt64(dtb1.Rows[0]["Tongtien"]);
            string _bangchu = UTL.Currency.ToString(_tongtien);

            txtTongtien.Text = _tongtien + "";
            txtBangchu.Text = _bangchu;
        }

        private void FrmThongke_Doanhthu_Theolop_Load(object sender, EventArgs e)
        {
            DataTable dtb = _dal.Select();
            cboKhoahoc.Properties.DataSource = dtb;
            cboKhoahoc.ItemIndex = -1;
        }

        private void btnIn_Click(object sender, EventArgs e)
        {
            var frm = new Report.FrmReport_Base();
            frm.Text = "In: " + Text;
            var rpt = new Report.XRDoanhthu_Theolop();

            //DateTime fr, to;
            //fr = XLTime.GetStartOfDay(dteFrom.DateTime);
            //to = XLTime.GetEndOfDay(dteTo.DateTime);
            DataTable tmp = _dal.Select_Current(DateTime.Now);
            string makhoa = tmp.Rows[0]["Makhoa"] + "";

            rpt.DataSource = _dal1.Select(makhoa);
            frm.SetReport(rpt);
            //frm.MdiParent = MdiParent;
            frm.Show();
            //frm.Activate()
        }

       
    }
}